﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.missions {
    import reprise.ui.*;
    import net.wooga.pets.models.world.vos.*;
    import net.wooga.pets.utils.*;

    public class MissionBrowserView extends UIComponent {

        private var missions:Array;

        private static const PADDING_TOP:int = 70;

        public function MissionBrowserView():void{
            this.missions = [];
            super();
        }
        override protected function initialize():void{
            super.initialize();
            cssID = "missionBrowser";
        }
        public function addMission(_arg1:MissionVO, _arg2:int=0):void{
            var _local3:MissionButton;
            if (_arg1){
                _local3 = new MissionButton();
                _local3.addCSSClass("missionButton");
                this.missions.splice(_arg2, 0, _local3);
                _local3.setStyle("top", String(PADDING_TOP));
                _local3.id = _arg1.id;
                RepriseUtils.addComponent(this, cssClasses);
                addChildAt(_local3, 0);
            };
            this.renderView();
        }
        public function removeMission(_arg1:MissionVO):void{
            var _local2:int;
            while (_local2 < this.missions.length) {
                if (this.missions[_local2].id == _arg1.id){
                    removeChild(this.missions[_local2]);
                    this.missions.splice(_local2, 1);
                    this.renderView();
                    return;
                };
                _local2++;
            };
        }
        public function removeMissionOnPos(_arg1:int):void{
            if ((this.missions.length - 1) >= _arg1){
                removeChild(this.missions[_arg1]);
                this.missions.splice(_arg1, 1);
                this.renderView();
            };
        }
        private function renderView():void{
            var _local2:MissionButton;
            var _local1:int;
            while (_local1 < this.missions.length) {
                _local2 = (this.missions[_local1] as MissionButton);
                _local2.setStyle("top", String((_local1 * PADDING_TOP)));
                _local1++;
            };
        }
        private function isMissionOnStage(_arg1:String):Boolean{
            var _local2:int;
            while (_local2 < this.missions.length) {
                if (this.missions[_local2].id == _arg1){
                    return (true);
                };
                _local2++;
            };
            return (false);
        }
        public function clear():void{
            this.missions = [];
        }

    }
}//package net.wooga.pets.views.missions 
